﻿namespace EasyGo.Logic.Managers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using EasyGo.Common;
    using EasyGo.Common.Auth;
    using EasyGo.Common.Commands;
    using EasyGo.Logic.Model;

    public class TaskManager : ITaskManager
    {
        private readonly IRepository<Task> taskRepository;

        public TaskManager(IRepository<Task> taskRepository)
        {
            this.taskRepository = taskRepository;
        }

        public void CreateTask(CreateTaskCommand command)
        {
            command.Validate();
            var task = new Task();
            task.Initialize(command, EasyGoPrincipal.Current.Id);
            Transaction.Execute(() => this.taskRepository.Create(task));
        }

    }
}
